#!/bin/sh
RESOURCE_NAME=wk-server-0.0.1-SNAPSHOT.jar
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi

tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
    echo 'App is running.'
else
    echo 'App is NOT running.'
fi

rm -f tpid
nohup  java  -Xmx256m -Xms256m -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC -jar ./$RESOURCE_NAME --spring.profiles.active=test  > debug.log 2>&1 &
echo Start Success!
tailf debug.log
